package Test;

import cn_cvs.SysUerMapper;
import entity.SysUser;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;
import java.util.logging.Logger;

public class SysUserMapperTest {
    private Logger logger = Logger.getLogger(String.valueOf(SysUserMapperTest.class));

    public void  count() throws Exception{
        SqlSession sqlSession = null;
        try {
            String resource = "mybatis-config.xml";
            InputStream is = Resources.getResourceAsStream(resource);
            SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
            sqlSession = factory.openSession();
            int count = sqlSession.getMapper(SysUerMapper.class).count();

        }finally {
            sqlSession.close();
        }
    }
    public void testUserListQuery()throws Exception{
        SqlSession sqlSession = null;
        List<SysUser> userList = null;
        try {
            String resource = "mybatis-confing.xml";
            InputStream is = Resources.getResourceAsStream(resource);
            SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
            sqlSession = factory.openSession();
            userList = sqlSession.getMapper(SysUerMapper.class).getUserList();
        }finally {
            sqlSession.close();

        }
    }
}
